using System;
using System.Runtime.CompilerServices;
using Nsb.Classes;
using YoshiBase.Classes;

namespace Yoshi.Classes
{
    [IgnoreNamespace]
    public class SavableData : PkgBase
    {
        private bool _saved = true;

        [AlternateSignature]
        public extern bool Saved();

        public bool Saved(bool ic)
        {
            bool sv = _saved;
            if (!Script.IsNullOrUndefined(ic))
            {
                _saved = ic;
                if (ic != sv)
                    UpdatePage();
            }
            return sv;
        }

        public void UpdatePage()
        {
            PageUpdate pu = new PageUpdate();
            pu.Saved = Saved();
            Master.Page.UpdatePage(pu);
        }
    }
}
